-
-
Notifications
You must be signed in to change notification settings - Fork 197
update(cli): Improve filtering of iOS logs #3389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e9bf8a7
to
596a867
Compare
596a867
to
f30ecbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation will cause some issues in Sidekick, as the projectData is not initialized in it. I have to think how to resolve this and come with a suggestion, but meanwhile you can take a look at my comments,
lib/services/ios-log-filter.ts
Outdated
@@ -4,62 +4,80 @@ import { cache } from "../common/decorators"; | |||
import * as iOSLogFilterBase from "../common/mobile/ios/ios-log-filter"; | |||
|
|||
export class IOSLogFilter extends iOSLogFilterBase.IOSLogFilter implements Mobile.IPlatformLogFilter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you are no longer calling the method from the base class, I suggest to remove the inheritance of iOSLogFilterBase.IOSLogFilter
. Implementing the interface is enough.
lib/services/ios-log-filter.ts
Outdated
|
||
constructor($loggingLevels: Mobile.ILoggingLevels, | ||
private $fs: IFileSystem, | ||
private $projectData: IProjectData) { | ||
super($loggingLevels); | ||
this.projectName = this.$projectData.projectName; | ||
this.loggingLevels = $loggingLevels; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of setting a new property here, you can just add access modifier to the $loggingLevels
in the constructor, for example:
constructor(private $loggingLevels: Mobile.ILoggingLevels,
test/services/ios-log-filter.ts
Outdated
data.originalDataArr.forEach((line, index) => { | ||
const actualData = logFilter.filterData(line, infoLogLevel, null); | ||
const expectedData = data.infoExpectedArr[index]; | ||
assert.deepEqual(actualData && actualData.trim(), expectedData && expectedData); | ||
assert.equal(actualData && actualData.trim(), expectedData && expectedData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this changed? Also can you fix the expected result - expectedData && expectedData
seems incorrect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think deepEqual
is not needed here as we are comparing strings.
test/services/ios-log-filter.ts
Outdated
testInjector = createTestInjector(); | ||
logFilter = testInjector.resolve(IOSLogFilter); | ||
}); | ||
// beforeEach(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove these comments
326b756
to
1f348e5
Compare
run ci |
4d51e32
to
2fbdcfa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall great work. Thank you for the effort.
lib/services/ios-log-filter.ts
Outdated
private $fs: IFileSystem, | ||
private $projectData: IProjectData) { | ||
super($loggingLevels); | ||
this.projectName = this.$projectData.projectName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might not work in Sidekick as there only one instance is created of the filter. Try getting projectData from projectDataService.getProjectData and using the project name from there on evry invocation of the filterData function or pass it as an argument if available where the method gets called.
} | ||
|
||
if (i === chunkLines.length - 1 && skipLastLine) { | ||
this.partialLine = currentLine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be grate if we could persist this per device identifier so that we don't mix lines from different devices. (This is not mandatory as it was the same way before).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, there is no way of receiving log messages from parallel processes with the latest version of CLI.
bc4754c
to
443afaf
Compare
run ci |
e624956
to
3f8b730
Compare
As @KristianDD mentioned, using So my suggestion is to use the same approach for iOS logs filtering - whenever CLI calls |
26b1a4c
to
2caaf19
Compare
When strating iOS Application, set the projectName to the log filter, so we can filter the logs by it. Same logic is used for Android, where we are using the PID of the started application. So introduce IDeviceLogOptions, where logLevel, pid and projectName can be set. Pass the projectName wherever is required in order to get it in startApplication.
…thods In order to make future refactorings easier, introduce a single object as an argument to some of the methods in devices' ApplicationManagers.
2caaf19
to
605df4a
Compare
This PR improves the overall behaviour of the IOSLogFilter within the CLI. We now filter data based on the following core assumption:
<app-name>(NativeScript)?[<pid>]
, where (NativeScript) might be missingMay 24 15:54:52 Dragons-iPhone NativeScript250(NativeScript)[356] <Notice>:
and directly follow a message with the first artefactRelying on these principles, we pass messages even if they are multiline (
console.dir
, stack-traces, etc).Unit tests have been slightly updated to reflect the currently expected behaviour.
This PR should address this issue: #3105 and is also related to supporting this feature: NativeScript/ios-jsc#884
Merge after telerik/mobile-cli-lib#1062